package com.atlanta.adopt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.concurrent.ExecutionException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HttpContext;

import android.app.Activity;
import android.app.AlertDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class ExperimentalImageButton extends Activity{
    /** Called when the activity is first created. */
    private String URL = "http://sms.petpoint.com/webservices/adoptablesearch/wsAdoptableAnimals.aspx?location=HM-Adoption&stage=Available&species=Dog&sex=A&agegroup=All&onhold=A&orderby=ID&colnum=3&authkey=uj36rnuzp324mmby22csi3mbfbt4y4p1h38ahympi8f5h6vyto&css=http://www.atlantahumane.org/css/pets.css";
    private Document doc ;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        

   /*     Document stuff = null;
        long start  = System.currentTimeMillis();
        try {
			doc = new NetTask().execute().get();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
	/*	Elements divs = doc.select("div.list-animal-photo");
		String [] elts = new String[divs.size()];
		
		int counter = 0;
        for (Element div : divs){
 		  elts[counter] = div.text();
 		  counter++;
 		}*/
     /*   counter = 0;
        divs = doc.select("div.list-animal-id");
        for (Element div : divs){
   		  elts[counter] += "\n\t" + div.text();
   		  counter++;
   		}
        counter = 0;
        divs = doc.select("div.list-animal-species");
        for (Element div : divs){
   		  elts[counter] += "\n\t" +div.text();
   		  counter++;
   		}
        counter = 0;
        divs = doc.select("div.list-animal-sexSN");
        for (Element div : divs){
   		  elts[counter] += "\n\t" +div.text();
   		  counter++;
   		}
        counter = 0;
        divs = doc.select("div.list-animal-breed");
        for (Element div : divs){
   		  elts[counter] += "\n\t" +div.text();
   		  counter++;
   		}
        counter = 0;
        divs = doc.select("div.list-animal-age");
        for (Element div : divs){
   		  elts[counter] += "\n\t" +div.text();
   		  counter++;
   		}*/ // this can go in the activity 
      //  Log.d("time", ""+(System.currentTimeMillis()-start));
        ScrollView sv = new ScrollView(this);
        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        sv.addView(ll);
       
        int x = 0;
      /*  for(counter = 0;counter<divs.size();counter++){

        }*/
        
        String url = "http://www.petango.com/sms/photos/910/d3968db7-9385-40af-be31-6d7ca52271f3_TN1.jpg";
    	
        ExpNetTask n = new ExpNetTask();
        
    	ImageButton i = new ImageButton(this);
    	try {
			i.setImageBitmap(n.execute(url).get());
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	ll.addView(i);
        this.setContentView(sv);

    }
}